<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>企业管理系统</title>
<meta name="renderer" content="webkit"/>
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
  <link rel="stylesheet" href="layui/css/layui.css" media="all"/>
    <script src="layui/layui.js"></script>
    <!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- jQuery -->
<script src="../plugins/jquery/jquery.min.js"></script>
  <script>
    //依赖 element 模块，否则无法进行功能性操作
    layui.use('element', function(){
        var element = layui.element;
    });
    function close() {
		if(confirm("您确定要退出登录？")) {
			$.ajax({
				url:"Sp/outlogin",
				type:"post",
				success:function(){
				},
				error:function(){
				}
			})
			window.location.href="/login.html";
		} else {}
	}
</script>
  <link rel="stylesheet" href="/layui/a.css"  media="all"/>
  <link rel="stylesheet" href="/layui/b.css" media="all"/>
</head>
<body>
<div class="layui-layout layui-layout-admin">
<div class="layui-header header header-demo">
  <div class="layui-main">
    <a class="logo" href="/">
      <img src="/layui/logo.png" alt="layui"/>
    </a>
    <div class="layui-form component" lay-filter="LAY-site-header-component"></div>
    <ul class="layui-nav">
      <!-- <li class="layui-nav-item ">
        <a href="http://qygl.gxkaijie.cn/">旧版系统<span class="layui-badge-dot"></span></a> 
      </li> -->
      <li class="layui-nav-item">
        <a id="quxianname" href="javascript:;"><!--<span class="layui-badge-dot" style="left:0; right: auto; margin: -4px 0 0 5px;"></span>--> </a>
        <a id="username" href="javascript:;"><!--<span class="layui-badge-dot" style="left:0; right: auto; margin: -4px 0 0 5px;"></span>--> </a>
        <!-- <dl class="layui-nav-child" style="left: auto; right: -22px; text-align: center;">
          <dd>
            <a href="" target="_blank">用户中心 <span class="layui-badge-dot" style="margin-top: -5px;"></span></a>
          </dd>
        </dl> -->
      </li>
      <li class="layui-nav-item layui-hide-xs">
        <a href="javascript:close();" target="_blank">退出登录 <span class="layui-badge-dot" style="margin-top: -5px;"></span></a>
      </li>
    </ul>
  </div>
</div>
  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
      
<ul class="layui-nav layui-nav-tree site-demo-nav">
  
  <li class="layui-nav-item layui-nav-itemed">
    <a class="javascript:;" href="javascript:;">原料系统</a>
    <dl class="layui-nav-child">
      <dd class="">
        <a href="addmate.html">原料制单</a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd>
        <a href="matecon.html">原料管理</a>
      </dd>
    </dl>
  </li>
  
  <li class="layui-nav-item layui-nav-itemed">
    <a class="javascript:;" href="javascript:;">货单系统</a>
    <dl class="layui-nav-child">
      <dd class="layui-this">
        <a href="addsell.html">货单制单</a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd class="">
        <a href="sellcon.html">货单管理</a>
      </dd>
    </dl>
  </li>
  
  <li class="layui-nav-item">
    <a class="javascript:;" href="javascript:;">库存系统</a>
    <dl class="layui-nav-child">
      <dd class="">
        <a href="stock.html">库存制单</a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd class="">
        <a href="stockGL.html">库存管理</a>
      </dd>
    </dl>
  </li>
  
  <li class="layui-nav-item">
    <a class="javascript:;" href="javascript:;">货款系统</a>
    <dl class="layui-nav-child">
      <dd class="">
        <a href="paycom.html">
          货款制单
        </a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd class="">
        <a href="paycomGL.html">
          货款管理
        </a>
      </dd>
    </dl>
  </li>
<li class="layui-nav-item">
    <a class="javascript:;" href="javascript:;">资金系统</a>
    <dl class="layui-nav-child">
      <dd class="">
        <a href="income.html">
          收入制单
        </a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd class="">
        <a href="incomeGL.html">
          收入管理
        </a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd class="">
        <a href="expend.html">
          支出制单
        </a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd class="">
        <a href="expendGL.html">
          支出管理
        </a>
      </dd>
    </dl>
  </li>
  <li class="layui-nav-item">
    <a class="javascript:;" href="javascript:;">统计报表</a>
    <dl class="layui-nav-child">
      <dd class="">
        <a href="yuanliaoTJ.html">
          原料统计
        </a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd class="">
        <a href="huodanTJ.html">
          货单统计
        </a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd class="">
        <a href="incomeTJ.html">
          收入统计
        </a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd class="">
        <a href="expendTJ.html">
          支出统计
        </a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd class="">
        <a href="qiankuanTJ.html">
          欠款统计
        </a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd class="">
        <a href="kucunTJ.html">
          库存统计
        </a>
      </dd>
    </dl>
  </li>
  <li class="layui-nav-item">
    <a class="javascript:;" href="javascript:;">用户</a>
    <dl class="layui-nav-child">
      <dd>
       <a href="/user.html">
          添加用户
        </a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd class="">
         <a href="/userGL.html">
          用户管理
        </a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd class="">
        <a href="updatepawod.html">
          修改密码
        </a>
      </dd>
    </dl>
    <dl class="layui-nav-child">
      <dd class="">
        <a href="outline.html">
          注销
        </a>
      </dd>
    </dl>
  </li>
  
  <li class="layui-nav-item" style="height: 30px; text-align: center"></li>
</ul>

    </div>
  </div>
  <div class="layui-tab layui-tab-brief" lay-filter="demoTitle">
    <div class="layui-body layui-tab-content site-demo site-demo-body">
    
    
      <div class="layui-tab-item layui-show">
        <div class="layui-main">
          <div id="LAY_preview">
              
<fieldset id="top1" class="layui-elem-field layui-field-title" style="margin-top: 10px;">
  <legend>货物信息</legend>
</fieldset>
 
<form class="layui-form" action="javascript:0;" lay-filter="example" method="post">
  <script>
  	var sum=0;
        function addm(){
    		var demoListView = $('#demoList')
		    var name=document.getElementById("name").value;
		    var modele=document.getElementById("modele").value;
		    var quantite=document.getElementById("quantite").value;
		    var unite=document.getElementById("unite").value;
		    var money=document.getElementById("money").value;
		    var total=accMul(money,quantite);
        	if(name==""||quantite==""||money==""){
        		alert("请填写完整货物信息!");
        		return 0;
        	}
        	$.ajax({
				url:"Sp/selestockquantite",
				type:"post",
				data:{
					"modele":modele,
					"quantite":quantite
					},
				dataType:"",
				success:function(a){
					if(!a){
						alert("该型号库存不足!");
					}else{
						var ta =document.getElementById("demoList");
						console.log(ta);
						var trf =document.getElementById("upload2");
						if(trf!=null){
							//document.getElementById("upload2").removeNode();
						}
					    sum=sum+total;
					    document.getElementById("sum").innerHTML=sum;
						var a=document.getElementById("tabletop").rows.length-1;
						var b=document.getElementById("tabletop").rows.length;
						var tr = $(['<tr id="upload1">'
							        ,'<td id="tdname'+a+'" contentEditable="true" style="width: 20%">'+ name +'</td>'
							        ,'<td id="tdmodele'+a+'" style="width: 20%">'+ modele +'</td>'
							        ,'<td id="tdquantite'+a+'" style="width: 10%">'+ quantite +'</td>'
							        ,'<td id="tdunite'+a+'" style="width: 7%">'+ unite +'</td>'
							        ,'<td id="tdmoney'+a+'" style="width: 13%">'+ money +'</td>'
							        ,'<td id="tdtotal'+a+'" style="width: 10%">'+ total +'</td>'
							        ,'<td style="width: 10%">'
							          ,'<button class="layui-btn layui-btn-xs layui-btn-danger" value='+total+' onclick="delem(this)">删除</button>'
							          ,'<button class="layui-btn layui-btn-xs layui-btn-sm" value='+total+' onclick="up(this)">编辑</button>'
							        ,'</td>','</tr>',
							        '<tr id="upload2">'
							        ,'<td id="tdname'+b+'" contentEditable="true" style="width: 20%"></td>'
							        ,'<td id="tdmodele'+b+'" style="width: 20%"></td>'
							        ,'<td id="tdquantite'+b+'" style="width: 10%"></td>'
							        ,'<td id="tdunite'+b+'" style="width: 7%"></td>'
							        ,'<td id="tdmoney'+b+'" style="width: 13%"></td>'
							        ,'<td id="tdtotal'+b+'" style="width: 10%">'+ sum +'</td>'
							        ,'<td style="width: 10%">'
							        ,'</td>','</tr>'
							      ].join(''));
							      
							      demoListView.append(tr);
					}
				},
				error:function(){
					alert("发生异常");
				}
			})
        	
        	 /*alert("发生异常");*/
         }
        function info(){
        	var tb=document.getElementById("demoList");
        	var b=new Array(100);
        	var count=0;
        	var rows = tb.rows;
        	for (var i = 0; i < rows.length; i++) {    //--循环所有的行

        	    var cells = rows[i].cells;　　// cells 集合返回表格中所有 <td> 或 <th> 元素。

        	    for (var j = 0; j < cells.length-1; j++) { 
        	        b[count]=cells[j].innerHTML;
        	        count++;
        	    }
        	}
        	
        	$.ajax({
				url:"Sp/ses?b="+b,
				type:"post",
				data:{
					"odd":document.getElementById("odd").value,
					"name2":document.getElementById("name2").value,
           		 "phone":document.getElementById("phone").value,
           		 "site":document.getElementById("site").value,
           		 "anq":document.getElementById("anq").value,
           		 "time":document.getElementById("date").value,
           		 "time2":document.getElementById("date2").value,
           		 "saisie":document.getElementById("saisie").value,
           		 "tupian":document.getElementById("img").value
					},
				dataType:"",
				success:function(a){
					alert(a);
				},
				error:function(){
					alert("发生异常");
				}
			})
        	
             /*  $.ajax({  
                 type: "POST",  
                 url: "Sp/ses?b="+b
                		 +"&odd="+document.getElementById("odd").value+
                		 +"&name2="+document.getElementById("name2").value+
                		 +"&phone="+document.getElementById("phone").value+
                		 +"&site="+document.getElementById("site").value+
                		 +"&anq="+document.getElementById("anq").value+
                		 +"&time="+document.getElementById("date").value+
                		 +"&time2="+document.getElementById("date2").value+
                		 +"&saisie="+document.getElementById("saisie").value+
                		 +"&tupian="+document.getElementById("saisie").value+
                		 +"&total="+document.getElementById("total").value
                		 
                		 ,  
                 contentType : 'application/json',  //默认值: "application/x-www-form-urlencoded"，发送信息至服务器时内容编码类型。  
                 success: function (msg) {
              	   alert(msg.value);
                 },error:function(msg){  
                     alert("failed"+msg.value);  
                 },  
        		//data:{"stu":"ssssss"}
                 //data: JSON.stringify(sendInfos)  
             });    */
        	 
        	
        	
        }
        function delem(obj){
        	var tr=obj.parentNode.parentNode;
            var tbody=tr.parentNode;
            tbody.removeChild(tr);
            sum-=obj.value;
		    document.getElementById("sum").innerHTML=sum;
		    //document.getElementByName("sum").innerHTML=sum;
    		//var demoListView = $('#demoList')
		       //删除
		      /* tr.find('.demo-delete').on('click', function(){
		        tr.remove();
		      });  */
        }
        function zhzs(value) {
        	   value = value.replace(/[^\d]/g, '').replace(/^0{1,}/g, '');
        	   if (value != '')
        	      value = parseFloat(value);//.toFixed(3);//小数点
        	   else
        	      value = parseFloat(0);//.toFixed(3);
        	   return value;
        	}
        function accMul(arg1,arg2)
        {
        var m=0,s1=arg1.toString(),s2=arg2.toString();
        try{m+=s1.split(".")[1].length}catch(e){}
        try{m+=s2.split(".")[1].length}catch(e){}
        return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
        }
        function up(btn) {
        	console.log(btn);
     	}
        function Vodd(btn) {
        	$.ajax({
				url:"Sp/seleoddbycid",
				type:"post",
				data:{
					"odd":btn,
					},
				dataType:"",
				success:function(a){
					if(!a){
						layer.alert("单号已存在");
						document.getElementById("odd").value="";
					}
				},
				error:function(){
					alert("发生异常");
				}
			})
     	}
</script>
<!-- <div  style="border-left:2px solid #00F;border-bottom:2px solid #00F;border-right:2px solid #00F;">边框开始 -->
	<div class="layui-upload-list">
		<table class="layui-table" id="tabletop">
			 <thead>
			        <tr><th>名称</th>
			        <th>型号</th>
			        <th>数量</th>
			        <th>单位</th>
			        <th>单价</th>
			        <th>合计(<label id="sum"></label>)</th>
			        <th>操作</th>
			      </tr>
			  </thead>     
			  <tbody id="demoList"></tbody>
		</table>
	</div>	    		 
  <div class="layui-form-item">
    <label class="layui-form-label">名称</label>
    <div class="layui-input-block">
      <input type="text" id="name" name="name" lay-reqtext="请输入名称" placeholder="请输入名称" class="layui-input"/>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">型号</label>
    <div class="layui-input-block">
      <select id="modele" name="modele" lay-search>
      </select>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">数量</label>
    <div class="layui-input-block">
      <input type="text" id="quantite" name="quantite" onblur="value=zhzs(this.value)" lay-reqtext="请输入数量" placeholder="请输入数量" class="layui-input"/>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">单位</label>
    <div class="layui-input-block">
      <select id="unite" name="unite">
        <option value="个" selected="selected">个</option>
        <option value="台">台</option>
      </select>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">单价</label>
    <div class="layui-input-block">
      <input type="text" id="money" name="money" lay-reqtext="请输入单价" placeholder="请输入单价" class="layui-input"/>
    </div>
  </div>
  <button type="button" class="layui-btn" onclick="addm()">添加货物</button> 
  <!-- </div>边框结束 -->

	<input type="hidden" name="faf" value="add">
	<div class="layui-form-item">
    <div class="layui-input-block">
      <input type="hidden" name="id" value="1">
    </div>
  </div>
  
	<fieldset id="top2" class="layui-elem-field layui-field-title" style="margin-top: 10px;">
	  <legend>订单信息</legend><button data-method="offset" data-type="auto" class="layui-btn layui-btn-normal">居中弹出</button>
	</fieldset>
  <div class="layui-form-item">
    <label class="layui-form-label">单号</label>
    <div class="layui-input-block">
      <input type="text" id="odd" name="odd" lay-verify="required" onblur="Vodd(this.value)" lay-reqtext="请输入单号" placeholder="请输入单号" class="layui-input"/>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">收货人名字</label>
    <div class="layui-input-block">
      <input type="text" id="name2" name="name2" lay-verify="required" lay-reqtext="请输入收货人名字" placeholder="请输入收货人名字" class="layui-input"/>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">收货人电话</label>
    <div class="layui-input-block">
      <input type="text" id="phone" name="phone" lay-verify="required" onblur="value=zhzs(this.value)" lay-reqtext="请输入收货人电话" placeholder="请输入收货人电话" class="layui-input"/>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">收货人地址</label>
    <div class="layui-input-block">
      <input type="text" id="site" name="site" lay-verify="required" lay-reqtext="请输入收货人地址" placeholder="请输入收货人地址" class="layui-input"/>
    </div>
  </div>
   <div class="layui-form-item">
    <label class="layui-form-label">销售人员</label>
    <div class="layui-input-block">
      <select id="anq" name="anq" lay-verify="required" lay-search>
      </select>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">发货时间</label>
      <div class="layui-input-inline">
        <input type="text" name="time" id="date" lay-verify="required" lay-reqtext="请选择发货时间" placeholder="请选择发货时间" autocomplete="off" class="layui-input"/>
      </div>
  </div>
  <div class="layui-form-item">
      <label class="layui-form-label">账期</label>
      <div class="layui-input-inline">
        <input type="text" name="time2" id="date2" lay-verify="required" lay-reqtext="请选择账期" placeholder="请选择账期" autocomplete="off" class="layui-input"/>
      </div>
    </div>
	 
	<div class="layui-upload">
	  <button type="button" class="layui-btn" id="test11">上传图片</button>
	  <div class="layui-upload-list">
	    <img class="layui-upload-img" id="demo11">
	    <p id="demoText"></p>
	<input type="hidden" name="img" id="img">
	  </div>
	</div> 
    
    
  <div class="layui-form-item">
    <label class="layui-form-label">制单人</label>
    <div class="layui-input-block">
      <input type="text" id="saisie" name="saisie" style="background-color: #DCDCDC;" disabled="disabled" class="layui-input"/>
    </div>
  </div>
  
  
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
  	<!-- <button type="button" class="layui-btn layui-btn-normal" onclick="info()">立即提交</button>  -->
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
      <button type="reset" class="layui-btn layui-btn-primary" onclick="print()"><i class="layui-icon layui-icon-print"></i></button>
    </div>
  </div>
  </form>
<!--   弹出层 -->
  <form class="layui-form" id="test" style="display:none">
  <div class="layui-form-item">
    <label class="layui-form-label">输入框</label>
    <div class="layui-input-block">
      <input type="text" name="title" required  lay-verify="required" placeholder="请输入标题" autocomplete="on" class="layui-input" id="username" style="width:100px">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">密码框</label>
    <div class="layui-input-inline">
      <input type="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="on" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">辅助文字</div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">选择框</label>
    <div class="layui-input-block">
     <select name="quiz" lay-search>
  <option value="">请选择</option>
  <optgroup label="城市记忆">
    <option value="你工作的第一个城市">你工作的第一个城市？</option>
  </optgroup>
  <optgroup label="学生时代">
    <option value="你的工号">你的工号？</option>
    <option value="你最喜欢的老师">你最喜欢的老师？</option>
  </optgroup>
</select>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">复选框</label>
    <div class="layui-input-block">
      <input type="checkbox" name="like[write]" title="写作" lay-skin="primary">
      <input type="checkbox" name="like[read]" title="阅读" checked lay-skin="primary">
      <input type="checkbox" name="like[dai]" title="发呆" lay-skin="primary">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">开关</label>
    <div class="layui-input-block">
      <input type="checkbox" name="switch" lay-skin="switch" lay-text="开启|关闭">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">单选框</label>
    <div class="layui-input-block">
      <input type="radio" name="sex" value="男" title="男">
      <input type="radio" name="sex" value="女" title="女" checked>
    </div>
  </div>
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label" >文本域</label>
    <div class="layui-input-block">
      <textarea lay-verify="required" name="desc" placeholder="请输入内容" class="layui-textarea"></textarea>
    </div>
  </div>
</form>
<button id="div">提交</button>
  
  </div>
  </div>
  </div>
  </div>
  </div>
  <div class="layui-footer footer footer-demo">
  <div class="layui-main">
    <p>
      Build By 广西海德塑料有限责任公司
    </p>
  </div>
</div>
</div>
<div id="LAY_democodejs">
<script>
function print() {
	var a=document.getElementById("tabletop").rows.length;
	
	 var html="";
	//html+="<table class="layui-table"><thead><tr><th>名称</th><th>型号</th><th>数量</th><th>单位</th><th>单价</th><th>合计(<label id='sum'></label>)</th></tr></thead></table>";
	html+=document.getElementById("top2").innerHTML;
	html+="<br/><label>单号："+document.getElementById('odd').value+"</label><br/><br/>";
	html+="<label>收货人："+document.getElementById('name2').value+"</label><br/><br/>";
	html+="<label>收货人电话："+document.getElementById('phone').value+"</label><br/><br/>";
	html+="<label>收货人地址："+document.getElementById('site').value+"</label><br/><br/>";
	html+="<label>销售人员："+document.getElementById('anq').value+"</label><br/><br/>";
	html+="<label>发货时间："+document.getElementById('date').value+"</label><br/><br/>";
	html+="<label>收货人："+document.getElementById('date2').value+"</label><br/><br/>";
	html+="<label>收货人："+document.getElementById('saisie').value+"</label><br/><br/>";
	html+=document.getElementById("top1").innerHTML;
	html+="<br/><table style='border: 1px solid black;width: 80%;' class='layui-table'><tr style='border: 1px solid black;'><th>名称</th><th>型号</th><th>数量</th><th>单位</th><th>单价</th><th>合计</th></tr>";
	for (var i = 0; i < a-1; i++) {
		var name="tdname"+i;
		var modele="tdmodele"+i;
		var quantite="tdquantite"+i;
		var unite="tdunite"+i;
		var money="tdmoney"+i;
		var total="tdtotal"+i;
		html+="<tr style='border: 1px solid black;'><th>"+
		document.getElementById(name).innerHTML+"</th><th>"+
		document.getElementById(modele).innerHTML+"</th><th>"+
		document.getElementById(quantite).innerHTML+"</th><th>"+
		document.getElementById(unite).innerHTML+"</th><th>"+
		document.getElementById(money).innerHTML+"</th><th>"+
		document.getElementById(total).innerHTML+"</th></tr>";
		}
	html+="</table>"
	/* var tb=document.getElementById("demoList");
	var rows = tb.rows;
	for (var i = 0; i < rows.length; i++) {    //--循环所有的行

	    var cells = rows[i].cells;　　// cells 集合返回表格中所有 <td> 或 <th> 元素。

	    for (var j = 0; j < cells.length-1; j++) { 

	    	html+="<label>名称："+document.getElementById('saisie').value+"</label><br/>";
	    	html+="<label>型号："+document.getElementById('saisie').value+"</label><br/>";
	    	html+="<label>名称："+document.getElementById('saisie').value+"</label><br/>";
	    	html+="<label>名称："+document.getElementById('saisie').value+"</label><br/>";
	    	html+="<label>名称："+document.getElementById('saisie').value+"</label><br/>";
	        b[count]=cells[j].innerHTML;
	    }
	} */
    var v = document.createElement("div");
    var f = ["<head>", "<style>", "body{font-size: 12px; color: #666;}", "table{width: 100%; border-collapse: collapse; border-spacing: 0;}", "th,td{line-height: 20px; padding: 9px 15px; border: 1px solid #ccc; text-align: left; font-size: 12px; color: #666;}", "a{color: #666; text-decoration:none;}", "*.layui-hide{display: none}",".picture{ }", "</style>", "</head>"].join("");
    $(v).append($("#table_info").html()+"</div>");
    var h = window.open("Print_window", "_blank");
    h.document.write(html);
    h.document.close();
    h.print();
    h.close(); 
}



layui.use(['layer','form', 'layedit', 'laydate'], function(){
  var form = layui.form
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate;
  
  
  layer.open({
	  type:1,
	  area:['500px','600px'],
	   title: 'tianxie'
	   ,content: $("#test"),
	   shade: 0,
	   btn: ['提交', '重置']
	   ,btn1: function(index, layero){
	   var kk=$("#username").val();
	   alert(kk);
	   },
	   btn2: function(index, layero){
	    alert("2222");
	    return false;
	   },
	 cancel: function(layero,index){ 
	    layer.closeAll();
	   }

	 }); 
  
  
  
 //获取型号select
  $.ajax({
		url:"Sp/seleallstockbymodele",
		type:"post",
		dataType:"",
		success:function(btn){
	          var select = $("#modele");//TypeID为HTML标签ID
		      	for (var j = 0; j < btn.count; j++) {
		      	  select.append("<option value='"+btn.data[j]+"'>"+btn.data[j]+"</option>");
		  		}
	          layui.form.render("select");
		},
		error:function(){
			alert("型号获取失败");
		}
	})
 //获取销售select
   $.ajax({
		url:"Sp/seleallanq",
		type:"post",
		dataType:"",
		success:function(btn){
	          var select = $("#anq");//TypeID为HTML标签ID
		      	for (var j = 0; j < btn.count; j++) {
		      	  select.append("<option value='"+btn.data[j]+"'>"+btn.data[j]+"</option>");
		  		}
	          layui.form.render("select");
		},
		error:function(){
			alert("人员获取失败");
		}
	})
	//日期
  laydate.render({
    elem: '#date',
    type: 'datetime'
  });
  laydate.render({
	    elem: '#date2',
	    type: 'date'
	  });

	var url = location.search;  
	if (url.indexOf("?") != -1) {
	  var str = url.substr(1);      
	}

	
	if(url!=null&&url!=""){
		$.ajax({
			url:"Sp/oddone",
			type:"get",
			data:{"odd":str},
			dataType:"",
			success:function(a){
				//表单赋值
			    form.val('example', {
			      "id": a.id
				  ,"time": a.time
				  ,"time2": a.time2
				  ,"anq": a.anq
				  ,"site": a.site
				  ,"phone": a.phone
				  ,"odd": a.odd
				  ,"name2": a.name2
			      ,"saisie": a.saisie
			      ,"faf": "up"
			    });
			     $.ajax({
					url:"Sp/xinsellone",
					type:"get",
					data:{"odd":str},
					dataType:"",
					success:function(a){
			    		var demoListView = $('#demoList')
						
    				for (var j = 0; j < a.length; j++) {
    					
						var tr = $(['<tr id="upload1">'
							        ,'<td contentEditable="true" style="width: 20%">'+ a[j].name +'</td>'
							        ,'<td style="width: 20%">'+ a[j].modele +'</td>'
							        ,'<td style="width: 10%">'+ a[j].quantite +'</td>'
							        ,'<td style="width: 7%">'+ a[j].unite +'</td>'
							        ,'<td style="width: 13%">'+ a[j].money +'</td>'
							        ,'<td style="width: 10%">'+ accMul(a[j].quantite,a[j].money) +'</td>'
							        ,'<td style="width: 10%">'
							          ,'<button class="layui-btn layui-btn-xs layui-btn-danger" value='+a[j].money+' onclick="delem(this)">删除</button>'
							          ,'<button class="layui-btn layui-btn-xs layui-btn-sm" value='+a[j].money+' onclick="up(this)">编辑</button>'
							        ,'</td>'
							      ,'</tr>'].join(''));
							      
							      demoListView.append(tr);
    				}
					},
					error:function(){
						if(str==null||str==""){
							
						}else
						alert("xinsell发生异常");
					}
				}) 
			},
			error:function(){
				if(str==null||str==""){
					
				}else
				alert("odd发生异常");
			}
		})
	
	}
	  var strcookie = document.cookie;//获取cookie字符串 
	      var arrcookie = strcookie.split("; ");//分割 
	      //遍历匹配 
	      for ( var i = 0; i < arrcookie.length; i++) { 
	          var arr = arrcookie[i].split("="); 
	          if (arr[0] == "username"){ 
					document.getElementById("saisie").value=arr[1].substring(arr[1].indexOf(":")+1);
			  		document.getElementById("username").innerHTML=arr[1];
	              return arr[1]; 
	          } 
	      } 
	  //监听提交
	   form.on('submit(demo1)', function(data){
		   demoListView = $('#upload1');
		if(demoListView.length==0){
			layer.alert("请添加货物");
		}else{
			info();
			
		}
		   /* $.ajax({
				url:"Sp/addsell",
				type:"post",
				data:data.field,
				dataType:"",
				success:function(a){
					layer.alert(a.result);
				},
				error:function(){
					alert("发生异常");
				}
			})
	    return false; */
	  }); 
	
});



layui.use('upload', function(){
	  var $ = layui.jquery
	  ,upload = layui.upload;
	  
	//普通图片上传
	  var uploadInst = upload.render({
	    elem: '#test11'
	    ,url: 'Sp/tupian' //改成您自己的上传接口
	    ,before: function(obj){
	      //预读本地文件示例，不支持ie8
	      obj.preview(function(index, file, result){
		    	console.log(file);
		    	document.getElementById('img').value=file.name;
	    	  $('#demo11').attr('src', result); //图片链接（base64）
	      });
	    }
	    ,done: function(res){
	      //如果上传失败
	      if(res.code > 0){
	        return layer.msg('上传失败');
	      }
	      //上传成功
	    }
	    ,error: function(){
	      //演示失败状态，并实现重传
	      var demoText = $('#demoText');
	      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
	      demoText.find('.demo-reload').on('click', function(){
	        uploadInst.upload();
	      });
	    }
	  });
});


</script>
</div>
</body>
</html>